<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.sql.DataSource" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %><%--
  Created by IntelliJ IDEA.
  User: Payboi
  Date: 2022/6/2
  Time: 14:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    //得到上下文引用
    Context context = new InitialContext();
    //得到DataSource引用
    DataSource dataSource = (DataSource) context.lookup("java:comp/env/jdbc/dzxcDS");
    Connection conn = null;
    //得到数据库连接
    conn = dataSource.getConnection();

    if(conn != null){
        out.println("<h1>"+"数据源连接成功！！！"+"</h1>");
    }else{
        out.println("数据源连接失败！！！");
    }


%>
</body>
</html>
